package org.sqlproc.engine.model;

import javax.persistence.Column;
import javax.persistence.Embeddable;

import org.hibernate.util.EqualsHelper;
import org.hibernate.validator.constraints.NotEmpty;

/**
*
* BasicType for PersonName.
*/
@Embeddable
public class PersonName {
    @Column(name = "FIRST", nullable = false, length = 100)
    @NotEmpty
    private String first;
    @Column(name = "LAST", nullable = false, length = 100)
    @NotEmpty
    private String last;

    public PersonName() {
    }

    public PersonName(String first, String last) {
        super();
//        Validate.notNull(first);
        this.first = first;
//        Validate.notNull(last);
        this.last = last;
    }

    public String getFirst() {
        return first;
    }

    /**
     * Creates a copy of this instance, but with another first.
     */
    public PersonName withFirst(String first) {
        if (EqualsHelper.equals(first, getFirst())) {
            return this;
        }
        return new PersonName(first, getLast());
    }

    public String getLast() {
        return last;
    }

    /**
     * Creates a copy of this instance, but with another last.
     */
    public PersonName withLast(String last) {
        if (EqualsHelper.equals(last, getLast())) {
            return this;
        }
        return new PersonName(getFirst(), last);
    }

	public void setFirst(String first) {
		this.first = first;
	}

	public void setLast(String last) {
		this.last = last;
	}
    
    
}
